package com.dkd.flow.emums;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.baomidou.mybatisplus.annotation.IEnum;
import com.fasterxml.jackson.annotation.JsonValue;

public enum FlowOperation implements IEnum<Integer> {

    SAVE(0, "保存"),
    LAUNCH(1, "发起"),
    AGREE(2, "同意"),
    REJECT_AND_END(3, "拒绝并结束"),
    TRANSFER(4, "转交"),
    RETURNED(5, "驳回"),//驳回重新提交后，回到当前审批人，不需要逐级审批
    RETURNED_ALL(8, "驳回所有"),//驳回所有，重新提交后，需要逐级审批。
    RE_SUBMIT(6, "重新提交"),
    RE_SUBMIT_ALL(10, "重新提交所有"),
    REVOKE(7, "撤回"),
    CC(9, "抄送");
    @EnumValue
    private final Integer value;
    private final String name;

    FlowOperation(Integer value,
                  String name) {
        this.value = value;
        this.name = name;
    }

    @Override
    @JsonValue
    public Integer getValue() {
        return value;
    }

    //通过value找到对应的类型
    public static FlowOperation getFlowOperationByValue(Integer value) {
        for (FlowOperation type : values()) {
            if (type.value.equals(value)) {
                return type;
            }
        }
        return null;
    }
}
